﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Defect_Tracking_System.Controllers
{
    public class SearchController : Controller
    {
        //
        // GET: /Search/
        [Authorize, HttpPost]
        public ActionResult Index(FormCollection form)
        {
            string keyWord = form["KeyWord"];
            string searchType = form["SearchType"];
            switch (searchType)
            {
                case "Defects":
                    return RedirectToAction("SearchDefect", "Defect", new { keyWord = keyWord, PageIndex = 1 });
                case "Projects":
                    return RedirectToAction("SearchProject", "Project", new { Keyword = keyWord, PageIndex = 1 });
                case "Users":
                    return RedirectToAction("Search", "Account", new { Keyword = keyWord, PageIndex = 1 });
                default:
                    return Redirect(Request.Url.ToString());
            }
        }

    }
}
